package chap4.Task2;
import java.util.Scanner;
public class Task6 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("从小到大输出1500个丑数:");

        long i, j, k, q = 0;
        for (i = 1; ; i++) {
            k = i;
            for (j = 2; k != 1; j++) {    //i和j一直动态变化，i是除数，j是被除数，j不可能大于i,i最后除尽变成1
                if (k % j == 0) {
                    if (j != 2 && j != 3 && j != 5)
                        break;
                    k = k / j;
                    j = j - 1;
                }
            }
            if (k == 1) {
                System.out.print(i + " ");
                q++;
                if (q == 1500) {
                    break;
                }
                if (q % 10 == 0) {
                    System.out.println();
                }

            }
        }
        System.out.println();
        System.out.println(q);
    }
}
